{include 'admin/layout/header_list'}
<link rel="stylesheet" href="__ADMIN_STATIC__/css/plugin.css?random={extendSetting('random')}">
<div class="ltcms_container">
    <div class="container_title">
        <form action="{LTCMS_ROUTE_PREFIX}/adminFunc/index" method="get" class="ltcms_search">
            <input name="menuId" type="text" placeholder="请输入菜单ID" {if isset($request['menuId'])}
            value="{$request['menuId']}" {/if} >
            <input name="action" type="text" placeholder="请输入控制器方法" {if isset($request['action'])}
            value="{$request['action']}" {/if} >
            <input name="module" type="text" placeholder="请输入命名空间控制器" {if isset($request['module'])}
            value="{$request['module']}" {/if} >
            <input name="moduleName" type="text" placeholder="请输入命名空间控制器名称" {if isset($request['moduleName'])}
            value="{$request['moduleName']}" {/if} >
            <input name="actionName" type="text" placeholder="请输入方法名称" {if isset($request['actionName'])}
            value="{$request['actionName']}" {/if} >
            <button type="submit" class="btn3">搜索</button>
        </form>
    </div>
    <section class="ltcms_content">
        <div class="ltcms_list">
            <table class="list_table">
                <colgroup>
                    <col width="40px">
                    <col width="100px">
                    <col width="120px">
                    <col width="120px">
                    <col width="180px">
                    <col width="80px">
                    <col width="80px">
                    <col width="80px">
                    <col width="100px">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <td class="th"><input id="selectAll" type="checkbox"></td>
                    <!--          <th>id</th>-->
                    <td class="th">控制器名称</td>
                    <td class="th">方法名称</td>
                    <td class="th">菜单</td>
                    <td class="th">命名空间控制器</td>
                    <td class="th">方法</td>
                    <td class="th">显示</td>
                    <td class="th">启用</td>
                    <td class="th">来源插件</td>
                    <td class="th">操作</td>
                </tr>
                </thead>
                <tbody>
                {if $rowData}
                {foreach $rowData["data"] $key $val}
                <tr class="tr">
                    <td><input class="checkbox" name="check_id" type="checkbox" value="{$val['id']}"></td>
                    <!--<td>{$val["id"]}</td>-->
                    <td>{$val["moduleName"]}</td>
                    <td>{$val["actionName"]}</td>
                    <td>{$val["menuIdFormat"]}</td>
                    <td>{$val["module"]}</td>
                    <td>{$val["action"]}</td>
                    <td>{$val["isShowFormat"]}</td>
                    <td>{$val["isEnableFormat"]}</td>
                    <td>{$val["plugins"]}</td>
                    <td>
                        <div class="btn4">
                            <a href="{LTCMS_ROUTE_PREFIX}/adminFunc/edit?id={$val['id']}">
                                <i title="编辑" alt="" class="btn4-img iconfont icon-bianji"></i>
                            </a>
                            <i onClick="runApi(this)" title="删除" data-close="4" data-submit-url="{LTCMS_ROUTE_PREFIX}/adminFunc?id={$val['id']}" data-method="delete" alt="" class="btn4-img del iconfont icon-delete"></i>
                        </div>
                    </td>
                </tr>
                {/foreach}
                {/if}
                </tbody>
            </table>
        </div>
    </section>
    <div class="list-bottom">
        <div class="bottom-left">
            <a href="{LTCMS_ROUTE_PREFIX}/adminFunc">
                <button class="btn2 trash">添加</button>
            </a>
            <button class="btn2 trash" onclick="updateControllerFunctionList(this)">重置控制器功能列表</button>
            <button class="btn2 del1" onclick="dataMoreDel(this)" data-close="3" data-submit-url="{LTCMS_ROUTE_PREFIX}/adminFunc?id="
                    data-method="delete">彻底删除
            </button>
<!--            <button class="btn1 del" onclick="deleteAll(this)">清空控制器功能列表//有重大问题,清空后超管都没有菜单显示了,无法操作重置控制器功能列表</button>-->
        </div>
        <div class="pages">
            {if $rowData}
            {php echo app("P_page")->getPageBarV2($rowData);}
            {/if}
        </div>
    </div>
</div>
<script src="__ADMIN_STATIC__/js/list.js?random={extendSetting('random')}"></script>

<script>
    function updateControllerFunctionList(obj) {
        var data_alert = $(obj).attr("data-alert");
        data_alert = typeof (data_alert) === "undefined" ? arrLang[lang]["publicAskSureExec"] : arrLang[lang][data_alert];
        layer.confirm(data_alert, {
            btn: [arrLang[lang]["confirm"], arrLang[lang]["cancel"]],
            title: arrLang[lang]["message"]
        }, function (index) {
            let msgIndex = layer.msg('正在处理', {
                icon: 16,
                shade: 0.05,
                time:false
            }, false);
            $.post("{LTCMS_ROUTE_PREFIX}/adminFunc/updateControllerFunctionList",
                {
                    _method: "put",
                },
                function (data, status) {
                    layer.close(msgIndex)
                    layer.msg(data.codeMsg, {icon: data.code === 0 ? 1 : 2, time: 3000});
                });
        });
    }

    function deleteAll(obj) {
        var data_alert = $(obj).attr("data-alert");
        data_alert = typeof (data_alert) === "undefined" ? arrLang[lang]["publicAskSureExec"] : arrLang[lang][data_alert];
        layer.confirm(data_alert, {
            btn: [arrLang[lang]["confirm"], arrLang[lang]["cancel"]],
            title: arrLang[lang]["message"]
        }, function (index) {
            let msgIndex = layer.msg('正在处理', {
                icon: 16,
                shade: 0.05,
                time:false
            });
            $.post("{LTCMS_ROUTE_PREFIX}/adminFunc/deleteAll",
                {
                    _method: "delete",
                },
                function (data, status) {
                    layer.close(msgIndex)
                    layer.msg(data.codeMsg, {icon: data.code === 0 ? 1 : 2, time: 1000});
                });
        });
    }
</script>
{include 'admin/layout/footer'}